<?php


namespace app\api\controller\wap;
use mall\library\Huobi;
use think\facade\Request;
use think\facade\Cache;

class Test extends Base
{
    // 设置 store 中的redis 类型
    private $storeRedis = 'redis';
    //个人信息
    public function info(){
        //exit('as');
        //phpinfo();exit;
        $params = Request::get();
        $amount = isset($params['amount'])?$params['amount']:'';
        $price = isset($params['price'])?$params['price']:'';
        $type = isset($params['type'])?$params['type']:'';
        $symbol = isset($params['symbol'])?$params['symbol']:'';
        $req = new Huobi();
        // 获取account-id, 用来替换ACCOUNT_ID
//        echo '<pre>';
//        print_r($req->get_account_accounts());
//        echo '</pre>';
//        $accounts = $req->get_account_accounts();
//        $redis = Cache::store('redis');
//        $redis->set('accounts_id',$accounts);
        //$a = json_decode($a, true);
        //p($a);


//        $marketTickersTmp = $req->get_market_tickers();
//        echo '<pre>';
//        $marketTickersTmp = array_column($marketTickersTmp['data'],null,'symbol');
//        $marketTickers['btcusdt'] = $marketTickersTmp['btcusdt'];
//        $marketTickers['ethusdt'] = $marketTickersTmp['ethusdt'];
//        $marketTickers['eosusdt'] = $marketTickersTmp['eosusdt'];
//
//        print_r($marketTickers);
//        echo '</pre>';

        // 获取账户余额示例
        echo '<pre>';
        print_r($req->get_balance());
        echo '</pre>';

        /*if(empty($params)) {
            return $this->returnAjax("缺少参数",0,[]);
        }*/
        echo '<pre>';
        //print_r($req->place_order(ACCOUNT_ID,$amount,$price,$symbol,$type));
        echo '</pre>';

        // 获取账户余额示例
        echo '<pre>';
        //print_r($req->get_balance());
        echo '</pre>';

    }

    /**
     * 获取 redis 类
     * @return \think\cache\Driver
     */
    private function redis() {
        return Cache::store($this->storeRedis);
    }


}
